﻿

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>节假日设置</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="../../../layuiadmin/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="../../../layuiadmin/style/admin.css" media="all">
    <link href="../../../layuiadmin/style/mystyle.css" rel="stylesheet" />
    <script src="../../../layuiadmin/lib/api.js"></script>
    <script src="../../../layuiadmin/lib/common.js"></script>
    <script src="../../../layuiadmin/lib/jquery.min.js"></script>
    <script src="../../../layuiadmin/layui/layui.js"></script>
    <script src="../../../layuiadmin/lib/system.js"></script>
    <script>
        //检查服务器是否已登录，没有登录则跳转至登录页。
        sys_islogin();
    </script>
</head>
<body>

    <div class="layui-form" lay-filter="layuiadmin-app-form-list" id="layuiadmin-app-form-list" style="padding: 20px 30px 0 0;">
        <input type="hidden" id="id" name="id" />
        <div class="layui-form-item">
            <label class="layui-form-label">节假日</label>
            <div class="layui-input-inline">
                <input type="text" class="layui-input" readonly id="startTime" name="startTime" lay-verify="required" placeholder="开始日期">
            </div>
            <div class="layui-form-mid">
                -
            </div>
            <div class="layui-input-inline">
                <input type="text" class="layui-input" readonly id="endTime" name="endTime" lay-verify="required" placeholder="结束日期">
            </div>

        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">类型</label>
            <div class="layui-input-inline" style="width: 400px;">
                <input type="radio" name="datetype" value="1" title="节假日" checked>
                <input type="radio" name="datetype" value="2" title="补班">
            </div>

        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">描述</label>
            <div class="layui-input-inline" style="width: 400px;">
                <input type="text" name="detail" id="detail" class="layui-input">
            </div>

        </div>
        <div class="layui-form-item layui-layout-admin" style="text-align:center;">
            <div class="layui-footer-new" style="background-color:#fff;">
                <button class="layui-btn" lay-submit lay-filter="save" id="save">保存</button>
                <button type="reset" lay-submit lay-filter="close" id="close" class="layui-btn layui-btn-primary">取消</button>

            </div>
        </div>
    </div>

    
    <script>
  layui.config({
    base: '../../../layuiadmin/' //静态资源所在路径
  }).extend({
      index: 'lib/index' //主入口模块
  }).use(['index', 'set', 'laydate'], function(){
      var $ = layui.$
          , form = layui.form;

      //监听提交
      form.on('submit(save)', function (data) {
          var field = data.field; //获取提交的字段
          var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
          
          //提交 Ajax 成功后，关闭当前弹层并重载表格
          $.ajax({
              url: "/HolidayMerber/AddHoliday",    //请求的url地址
              dataType: "json",   //返回格式为json
              async: true,//请求是否异步，默认为异步，这也是ajax重要特性
              data: { arg: JSON.stringify(field) },    //参数值
              type: "POST",   //请求方式
              beforeSend: function () {
                  //请求前的处理
              },
              success: function (data) {
                  //请求成功时处理
                  if (data> 0) {
                      layer.msg("添加成功");
                      parent.layui.table.reload('LAY-app-content-list'); //重载表格
                      parent.layer.close(index); //再执行关闭
                  }
                  else {
                      layer.msg("添加失败，请稍后重试");
                  }
              },
              error: function (res) {
                  layer.msg("添加失败，请联系技术人员");
              }
          });

      });


      var laydate = layui.laydate;
      //开始日期
      var insStart = laydate.render({
          elem: '#startTime'
          , done: function (value, date) {
              //更新结束日期的最小日期
              insEnd.config.min = lay.extend({}, date, {
                  month: date.month - 1
              });

              //自动弹出结束日期的选择器
              insEnd.config.elem[0].focus();
          }
      });

      //结束日期
      var insEnd = laydate.render({
          elem: '#endTime'
          , done: function (value, date) {
              //更新开始日期的最大日期
              insStart.config.max = lay.extend({}, date, {
                  month: date.month - 1
              });
          }
      });

      
  });

        //关闭弹窗
        $("#close").on("click", function () {
            var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
            parent.layer.close(index); //再执行关闭
        });
            
       
    </script>
</body>
</html>